### -*- coding: utf-8 -*- #############################################
# Разработано Паэглит Арвидом (http://arvid.dp.ua/)
# Все права защищены, 2007
#
# Developed by Paeglit Arvid (http://arvid.dp.ua/)
# All right reserved, 2007
#######################################################################
"""View class for the Zope 3 based useraddmail

$Id: useraddmailableedit.py 35 2007-12-11 12:38:03Z Arvi3D $
"""
__author__  = "Arvid"
__license__ = "GPL"
__version__ = "$Revision: 35 $"
__date__ = "$Date: 2007-12-11 12:38:03 +0000 (Tue, 11 Dec 2007) $"

from zope.interface import Interface
from zope.schema import getFieldNamesInOrder
from zope.app.i18n import ZopeMessageFactory as _

from datetime import datetime

class UserAddMailableEdit(object) :

    def getData(self,*kv,**kw) :
        self.ann = self.schema(self.context)
        return [(x, getattr(self.ann, x)) for x in  getFieldNamesInOrder(self.schema)]

    def setData(self,d,**kw) :
        for x, val in d.items():
            setattr(self.ann, x, val)
        formatter = self.request.locale.dates.getFormatter('dateTime', 'medium')
        return _("Updated on ${date_time}",
                           mapping={'date_time' : formatter.format(datetime.utcnow())})
